package dao;

import com.sun.xml.rpc.processor.modeler.j2ee.xml.string;
import entity.User;
import entity.Choose;
import entity.Manager;
import entity.Job;
import entity.Stu;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.*;



/**
 *
 * 
 */
public class UserChecker {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    private Connection con;
    private Statement stmt;
    private ResultSet rs;
    private PreparedStatement pstmt;
    private User user2 = new User();//
    private Manager manager2 = new Manager();
    private Job job = new Job();
    private Job job2 = new Job();
    private Stu stu = new Stu();
    private Stu stu2 = new Stu();
    private Choose choose1 = new Choose();
    private Choose[] choose ;
    int num;
    String userName = "root";
    String userPasswd = "000000";
    String dbName = "jobtest";
    String url = "jdbc:mysql://localhost/" + dbName + "?user=" + userName + "&password=" + userPasswd + "&useUnicode=true&characterEncoding=UTF-8";
    private String msg;

    public UserChecker() {
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public Choose[] getChoose() {
        return choose;
    }

    public Choose getChoose(int index) {
        return choose[index];
    }

    public void setChoose(Choose[] choose) {
        this.choose = choose;
    }

    public void connectDB() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
        //Class.forName("com.mysql.jdbc.Driver"); //1
        con = DriverManager.getConnection(url);//2
        stmt = con.createStatement();//3
    }

    public void closeDB() throws SQLException {
        //
        con.close();
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /*
     *     *
    */
    public User validate(User user)  {
        try {
                      rs = stmt.executeQuery("SELECT * FROM userinf WHERE number='" + user.getNumber() + "' AND pwd='" + user.getPwd() + "'");
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            if (rs.next()) {
                                user2.setId(rs.getInt("id"));
                user2.setNumber(rs.getString("number"));
                user2.setUsername(rs.getString("username"));
                user2.setPwd(rs.getString("pwd"));
                user2.setAve1(rs.getDouble("ave1"));
                user2.setAve2(rs.getDouble("ave2"));
                user2.setAve3(rs.getDouble("ave3"));
                user2.setAve4(rs.getDouble("ave4"));
                user2.setRank1(rs.getDouble("rank1"));
                user2.setRank2(rs.getDouble("rank2"));
                user2.setRank3(rs.getDouble("rank3"));
                user2.setRank4(rs.getDouble("rank4"));
                user2.setE1(rs.getDouble("e1"));
                user2.setE2(rs.getDouble("e2"));
                user2.setE3(rs.getDouble("e3"));
                user2.setE4(rs.getDouble("e4"));
                user2.setCet4(rs.getDouble("cet4"));
                user2.setFail(rs.getDouble("fail"));
                user2.setC(rs.getDouble("c"));
                user2.setCexp(rs.getDouble("cexp"));
                user2.setPro(rs.getDouble("pro"));
                user2.setPhyA1(rs.getDouble("phyA1"));
                user2.setPhyA2(rs.getDouble("phyA2"));
                user2.setCircuit(rs.getDouble("circuit"));
                user2.setLa(rs.getDouble("la"));
                user2.setIsteacher(rs.getString("isteacher"));
                user2.setSub(rs.getString("sub"));
                user2.setIntro(rs.getDouble("intro"));
                user2.setOs(rs.getDouble("os"));
                user2.setMathA1(rs.getDouble("mathA1"));
                user2.setMathA2(rs.getDouble("mathA2"));





//            List list = new ArrayList();
//            list.add(user2);
            } else {
                return null;
            }
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        return user2; //
    }


    /*
     *    *
    */
    public Manager validate(Manager manager) throws SQLException {
               rs = stmt.executeQuery("SELECT * FROM manager WHERE number='" +    //4
                manager.getNumber() + "' AND pwd='" +
                manager.getPwd() + "'");
        if (rs.next()) {               manager2.setId(rs.getInt("id"));
            manager2.setNumber(rs.getString("number"));
            manager2.setPwd(rs.getString("pwd"));
//            List list = new ArrayList();
//            list.add(user2);
        } else {
            return null;
        }
        return manager2; 
    }


     /*
     **
    */
    public int adduserinfo(User user)  {
        try {
            rs = stmt.executeQuery("SELECT * FROM userinf WHERE number='" + user.getNumber() + "' AND pwd='" + user.getPwd() + "'");
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            if (rs.next()) {
                              msg = "already exist";
                return 0;
//            List list = new ArrayList();
//            list.add(user2);
            } 
            else {
                pstmt = con.prepareStatement("insert into userinf(number,pwd,username,mathA1,mathA2,la,phyA1,intro,c,cexp,e1,e2,ave1,fail,rank1,cet4,pro,phyA2,circuit,e3,e4,ave2,rank2,os,ave3,rank3,ave4,rank4,sub,isteacher) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
                pstmt.setString(1, user.getNumber());
                pstmt.setString(2, user.getPwd());
                pstmt.setString(3, user.getUsername());
                pstmt.setDouble(4, user.getMathA1());
                pstmt.setDouble(5, user.getMathA2());
                pstmt.setDouble(6, user.getLa());
                pstmt.setDouble(7, user.getPhyA1());
                pstmt.setDouble(8, user.getIntro());
                pstmt.setDouble(9, user.getC());
                pstmt.setDouble(10, user.getCexp());
                pstmt.setDouble(11, user.getE1());
                pstmt.setDouble(12, user.getE2());
                pstmt.setDouble(13, user.getAve1());
                pstmt.setDouble(14, user.getFail());
                pstmt.setDouble(15, user.getRank1());
                pstmt.setDouble(16, user.getCet4());
                pstmt.setDouble(17, user.getPro());
                pstmt.setDouble(18, user.getPhyA2());
                pstmt.setDouble(19, user.getCircuit());
                pstmt.setDouble(20, user.getE3());
                pstmt.setDouble(21, user.getE4());
                pstmt.setDouble(22, user.getAve2());
                pstmt.setDouble(23, user.getRank2());
                pstmt.setDouble(24, user.getOs());
                pstmt.setDouble(25, user.getAve3());
                pstmt.setDouble(26, user.getRank3());
                pstmt.setDouble(27, user.getAve4());
                pstmt.setDouble(28, user.getRank4());
                pstmt.setString(29, user.getSub());
                pstmt.setString(30, user.getIsteacher());
                pstmt.executeUpdate();
                 return 1;
            }
         
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
            return 2;
       }
    



    /*
     *
     * 
    */
    public int updateuserinfo(User user)  {
        int count=0;
        try {
            pstmt = con.prepareStatement("update userinf set username=?,mathA1=?,mathA2=?,la=?,phyA1=?,intro=?,c=?,cexp=?,e1=?,e2=?," +
                    "ave1=?,fail=?,rank1=?,cet4=?,pro=?,phyA2=?,circuit=?,e3=?,e4=?,ave2=?,rank2=?,os=?,ave3=?,rank3=?,ave4=?,rank4=? where id =?");
//                pstmt.setString(1, user.getNumber());
//                pstmt.setString(2, user.getPwd());
                pstmt.setInt(27, user.getId());///////////////
                pstmt.setString(1, user.getUsername());/////////////////
                pstmt.setDouble(2, user.getMathA1());
                pstmt.setDouble(3, user.getMathA2());
                pstmt.setDouble(4, user.getLa());
                pstmt.setDouble(5, user.getPhyA1());
                pstmt.setDouble(6, user.getIntro());
                pstmt.setDouble(7, user.getC());
                pstmt.setDouble(8, user.getCexp());
                pstmt.setDouble(9, user.getE1());
                pstmt.setDouble(10, user.getE2());
                pstmt.setDouble(11, user.getAve1());
                pstmt.setDouble(12, user.getFail());
                pstmt.setDouble(13, user.getRank1());
                pstmt.setDouble(14, user.getCet4());
                pstmt.setDouble(15, user.getPro());
                pstmt.setDouble(16, user.getPhyA2());
                pstmt.setDouble(17, user.getCircuit());
                pstmt.setDouble(18, user.getE3());
                pstmt.setDouble(19, user.getE4());
                pstmt.setDouble(20, user.getAve2());
                pstmt.setDouble(21, user.getRank2());
                pstmt.setDouble(22, user.getOs());
                pstmt.setDouble(23, user.getAve3());
                pstmt.setDouble(24, user.getRank3());
                pstmt.setDouble(25, user.getAve4());
                pstmt.setDouble(26, user.getRank4());
//                pstmt.setString(29, user.getSub());
//                pstmt.setString(30, user.getIsteacher());
                count = pstmt.executeUpdate();
                

        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
       return count;
               
       }

    /*
     *
     *
    */

       public Job jobinfo(Job job){
       try {           rs = stmt.executeQuery("SELECT * FROM job WHERE jobname='" + job.getJobname()+"'");
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            if (rs.next()) {
                              job2.setJobname (rs.getString("jobname"));
                job2.setJob (rs.getString("job"));
                return job2;
//            List list = new ArrayList();
//            list.add(user2);
            } else {
                
            }

<<<<<<< .mine
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
            return job2;

       }

/*
     **
    */

     public int jobchooselist()
     {
         num = 0;
        try {
            rs = stmt.executeQuery("SELECT * FROM choose");
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            while (rs.next()) {
                num++;
            }
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (num > 0) {
            choose = new Choose[num];
            try {
                rs = stmt.executeQuery("SELECT * FROM choose");
            } catch (SQLException ex) {
                Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
            }
            for (int i = 0; i < num; i++) {
                try {
                    rs.next();
                } catch (SQLException ex) {
                    Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
                }
                choose[i] = new Choose();
                try {
                    choose[i].setId(rs.getInt("id"));
                } catch (SQLException ex) {
                    Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    choose[i].setName(rs.getString("name"));
                } catch (SQLException ex) {
                    Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
                }
                try {
                    choose[i].setChoice(rs.getString("choice"));
                } catch (SQLException ex) {
                    Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
                }

            }
        }
        return num;

       }

     /*
     *
     *
    */

     public void updatejobchoose(Choose choose1)  {
        
        try {
                pstmt = con.prepareStatement("update choose set choice=? where ID =?");
                System.out.println("#####################id "+choose1.getId()+"#####choice "+choose1.getChoice());
                pstmt.setInt(2, choose1.getId());
                pstmt.setString(1, choose1.getChoice());///////////////
                pstmt.executeUpdate();
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
       
     }

     /*
     **
    */

      public Stu updatestulist(String num)  {

         try {          rs = stmt.executeQuery("SELECT * FROM stu WHERE num='" + num + "'");
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            if (rs.next()) {

                stu2.setNum (rs.getString("num"));
                stu2.setJob (rs.getString("job"));
                stu2.setSub (rs.getString("sub"));
                stu2.setIsteacher (rs.getString("isteacher"));
                stu2.setMathA1 (rs.getDouble("mathA1"));
                stu2.setMathA2 (rs.getDouble("mathA2"));
                stu2.setLa (rs.getDouble("la"));
                stu2.setPhyA1 (rs.getDouble("phyA1"));
                stu2.setPhyA2 (rs.getDouble("phyA2"));
                stu2.setIntro (rs.getDouble("intro"));
                stu2.setC (rs.getDouble("c"));
                stu2.setCexp (rs.getDouble("cexp"));
                stu2.setE1 (rs.getDouble("e1"));
                stu2.setE2 (rs.getDouble("e2"));
                stu2.setE3 (rs.getDouble("e3"));
                stu2.setE4 (rs.getDouble("e4"));
                stu2.setRank1 (rs.getDouble("rank1"));
                stu2.setRank2 (rs.getDouble("rank2"));
                stu2.setRank3 (rs.getDouble("rank3"));
                stu2.setRank4 (rs.getDouble("rank4"));
                stu2.setAve1 (rs.getDouble("ave1"));
                stu2.setAve2 (rs.getDouble("ave2"));
                stu2.setAve3 (rs.getDouble("ave3"));
                stu2.setAve4 (rs.getDouble("ave4"));
                stu2.setOs (rs.getDouble("os"));
                stu2.setFail (rs.getDouble("fail"));
                stu2.setCircuit (rs.getDouble("circuit"));
                stu2.setCet4 (rs.getDouble("cet4"));
                stu2.setPro (rs.getDouble("pro"));
                
            } else {
                return null;
            }

        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }

            return stu2;

     }

       /*
     **
    */


      public int manastuadd(Stu stu)  {
        try {
         rs = stmt.executeQuery("SELECT * FROM stu WHERE num='" + stu.getNum() + "'");
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            if (rs.next()) {
               msg = "already exist";
                return 0;
//            List list = new ArrayList();
//            list.add(user2);
            }
            else {
                pstmt = con.prepareStatement("insert into stu(num,mathA1,mathA2,la,phyA1,intro,c,cexp,e1,e2,ave1,fail,rank1,cet4,pro,phyA2,circuit,e3,e4,ave2,rank2,os,ave3,rank3,ave4,rank4,sub,isteacher,job) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
                pstmt.setString(1, stu.getNum());
                pstmt.setDouble(2, stu.getMathA1());
                pstmt.setDouble(3, stu.getMathA2());
                pstmt.setDouble(4, stu.getLa());
                pstmt.setDouble(5, stu.getPhyA1());
                pstmt.setDouble(6, stu.getIntro());
                pstmt.setDouble(7, stu.getC());
                pstmt.setDouble(8, stu.getCexp());
                pstmt.setDouble(9, stu.getE1());
                pstmt.setDouble(10, stu.getE2());
                pstmt.setDouble(11, stu.getAve1());
                pstmt.setDouble(12, stu.getFail());
                pstmt.setDouble(13, stu.getRank1());
                pstmt.setDouble(14, stu.getCet4());
                pstmt.setDouble(15, stu.getPro());
                pstmt.setDouble(16, stu.getPhyA2());
                pstmt.setDouble(17, stu.getCircuit());
                pstmt.setDouble(18, stu.getE3());
                pstmt.setDouble(19, stu.getE4());
                pstmt.setDouble(20, stu.getAve2());
                pstmt.setDouble(21, stu.getRank2());
                pstmt.setDouble(22, stu.getOs());
                pstmt.setDouble(23, stu.getAve3());
                pstmt.setDouble(24, stu.getRank3());
                pstmt.setDouble(25, stu.getAve4());
                pstmt.setDouble(26, stu.getRank4());
                pstmt.setString(27, stu.getSub());
                pstmt.setString(28, stu.getIsteacher());
                pstmt.setString(29, stu.getJob());
                pstmt.executeUpdate();
                 return 1;
            }

        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
            return 2;
       }






=======
<<<<<<< .mine
//            List list = new ArrayList();
//            list.add(user2);
            } else {
                return null;
            }
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        return job;
    }



/*
     *     *
    */
public int manaJobInfoUpdate(Job job2)  {
        int count=0;
        try {
            pstmt = con.prepareStatement("update job set job=? where jobname =?");
//                pstmt.setString(1, user.getNumber());
//                pstmt.setString(2, user.getPwd());
                pstmt.setString(2, job2.getJobname());///////////////
               // pstmt.setString(1, stu.getUsername());/////////////////
                pstmt.setString(1, job2.getJob());
                count = pstmt.executeUpdate();


        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
       return count;

       }




     }
/*
     *     *
    */
public List<String> getManaJobNameInfoList()  {
     List<String> list = new ArrayList<String>();
        try {
           rs = stmt.executeQuery("SELECT jobname FROM job order by ID");

            while (rs.next()) {
                list.add(rs.getString("jobname"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }

            return list;
       }

/*
     *     *
    */
public List<String> getChooseList()  {
     List<String> list = new ArrayList<String>();
        try {
          rs = stmt.executeQuery("SELECT * FROM choose c");

            while (rs.next()) {
                list.add(rs.getString("choice"));
            }
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }

            return list;
       }


=======
<<<<<<< .mine
>>>>>>> .r9
/*
 *
 *
*/
public List<Stu> warning(String job){
    List<Stu> stu = null;
    try {
           rs = stmt.executeQuery("SELECT * FROM stu s WHERE s.job="+job);
//        rs = stmt.executeQuery("SELECT * FROM stu");
            stu = new ArrayList<Stu>();

            while(rs.next()){
                Stu stuTmp= new Stu();
                if(rs.getString("mathA1")==null)stuTmp.setMathA1(0);
               else if(Double.parseDouble(rs.getString("mathA1"))>60){
                    stuTmp.setMathA1(1);
                }else{
                    stuTmp.setMathA1(0);
                }
                

                if(rs.getString("mathA2")==null)stuTmp.setMathA2(0);
                else if(Double.parseDouble(rs.getString("mathA2"))>60){
                    stuTmp.setMathA2(1);
                }else{
                    stuTmp.setMathA2(0);
                }

                if(rs.getString("la")==null)stuTmp.setLa(0);
                else if(Double.parseDouble(rs.getString("la"))>60){
                    stuTmp.setLa(1);
                }else{
                    stuTmp.setLa(0);
                }
                if(rs.getString("phyA1")==null) stuTmp.setPhyA1(0);
                else if(Double.parseDouble(rs.getString("phyA1"))>60){
                    stuTmp.setPhyA1(1);
                }else{
                    stuTmp.setPhyA1(0);
                }
                if(rs.getString("intro")==null) stuTmp.setIntro(0);
                else if(Double.parseDouble(rs.getString("intro"))>60){
                    stuTmp.setIntro(1);
                }else{
                    stuTmp.setIntro(0);
                }
if(rs.getString("c")==null)stuTmp.setC(0);
               else  if(Double.parseDouble(rs.getString("c"))>60){
                    stuTmp.setC(1);
                }else{
                    stuTmp.setC(0);
                }
                if(rs.getString("cexp")==null)stuTmp.setCexp(0);
                else if(Double.parseDouble(rs.getString("cexp"))>60){
                    stuTmp.setCexp(1);
                }else{
                    stuTmp.setCexp(0);
                }
if(rs.getString("e1")==null)stuTmp.setE1(0);
                else if(Double.parseDouble(rs.getString("e1"))>60){
                    stuTmp.setE1(1);
                }else{
                    stuTmp.setE1(0);
                }
   if(rs.getString("e2")==null)stuTmp.setE2(0);
                else if(Double.parseDouble(rs.getString("e2"))>60){
                    stuTmp.setE2(1);
                }else{
                    stuTmp.setE2(0);
                }
if(rs.getString("ave1")==null)stuTmp.setAve1(0);
                else if(Double.parseDouble(rs.getString("ave1"))>60){
                    stuTmp.setAve1(1);
                }else{
                    stuTmp.setAve1(0);
                }
                if(rs.getString("fail")==null)stuTmp.setFail(0);
                else if(Double.parseDouble(rs.getString("fail"))>0){
                    stuTmp.setFail(1);
                }else{
                    stuTmp.setFail(0);
                }
if(rs.getString("rank1")==null)stuTmp.setRank1(0);
                else if(Double.parseDouble(rs.getString("rank1"))<10){
                    stuTmp.setRank1(1);
                }else{
                    stuTmp.setRank1(0);
                }
                if(rs.getString("cet4")==null)stuTmp.setCet4(0);
                else if(Double.parseDouble(rs.getString("cet4"))>425){
                    stuTmp.setCet4(1);
                }else{
                    stuTmp.setCet4(0);
                }
if(rs.getString("pro")==null)stuTmp.setPro(0);
                else if(Double.parseDouble(rs.getString("pro"))>60){
                    stuTmp.setPro(1);
                }else{
                    stuTmp.setPro(0);
                }
                if(rs.getString("phyA2")==null)stuTmp.setPhyA2(0);
                else if(Double.parseDouble(rs.getString("phyA2"))>60){
                    stuTmp.setPhyA2(1);
                }else{
                    stuTmp.setPhyA2(0);
                }
if(rs.getString("circuit")==null)stuTmp.setCircuit(0);
                else if(Double.parseDouble(rs.getString("circuit"))>60){
                    stuTmp.setCircuit(1);
                }else{
                    stuTmp.setCircuit(0);
                }
                if(rs.getString("e3")==null)stuTmp.setE3(0);
                else if(Double.parseDouble(rs.getString("e3"))>60){
                    stuTmp.setE3(1);
                }else{
                    stuTmp.setE3(0);
                }
if(rs.getString("e4")==null)stuTmp.setE4(0);
                else if(Double.parseDouble(rs.getString("e4"))>60){
                    stuTmp.setE4(1);
                }else{
                    stuTmp.setE4(0);
                }
                if(rs.getString("ave2")==null) stuTmp.setAve2(0);
                else if(Double.parseDouble(rs.getString("ave2"))>60){
                    stuTmp.setAve2(1);
                }else{
                    stuTmp.setAve2(0);
                }
if(rs.getString("rank2")==null)stuTmp.setRank2(0);
                else if(Double.parseDouble(rs.getString("rank2"))<10){
                    stuTmp.setRank2(1);
                }else{
                    stuTmp.setRank2(0);
                }
                if(rs.getString("os")==null) stuTmp.setOs(0);
               else  if(Double.parseDouble(rs.getString("os"))>60){
                    stuTmp.setOs(1);
                }else{
                    stuTmp.setOs(0);
                }
                if(rs.getString("ave3")==null)stuTmp.setAve3(0);
               else  if(Double.parseDouble(rs.getString("ave3"))>60){
                    stuTmp.setAve3(1);
                }else{
                    stuTmp.setAve3(0);
                }
                if(rs.getString("rank3")==null)stuTmp.setRank3(0);
               else  if(Double.parseDouble(rs.getString("rank3"))<10){
                    stuTmp.setRank3(1);
                }else{
                    stuTmp.setRank3(0);
                }
                if(rs.getString("ave4")==null)stuTmp.setAve4(0);
                else if(Double.parseDouble(rs.getString("ave4"))>60){
                    stuTmp.setAve4(1);
                }else{
                    stuTmp.setAve4(0);
                }
                if(rs.getString("rank4")==null)stuTmp.setRank4(0);
                else if(Double.parseDouble(rs.getString("rank4"))<10){
                    stuTmp.setRank4(1);
                }else{
                    stuTmp.setRank4(0);
                }
               stuTmp.setIsteacher(rs.getString("isteacher"));
               stuTmp.setJob(rs.getString("job"));


                stu.add(stuTmp);
            }=======

>>>>>>> .r10
>>>>>>> .r19

         
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        return stu;
}









 /*
     *
     *
    */


      public int manajobinfoadd(Job job)  {
        try {
            rs = stmt.executeQuery("SELECT * FROM job WHERE jobname='" + job.getJobname() + "'");
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            if (rs.next()) {
              msg = "already exist";
                return 0;
//            List list = new ArrayList();
//            list.add(user2);
            }
            else {
                pstmt = con.prepareStatement("insert into job(jobname,job) values(?,?)");
                pstmt.setString(1, job.getJobname());
                pstmt.setString(2, job.getJob());
                pstmt.executeUpdate();
                 return 1;
            }

        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
            return 2;
       }



      /*
     *     *
    */
public int manajobinfodel(Job job) throws SQLException {
        int count = 0;
        pstmt = con.prepareStatement("delete from job where jobname=?");
        pstmt.setString(1, job.getJobname());
        count = pstmt.executeUpdate();
        return count;
    }

 /*
     *     *
    */


public Job validate(Job job)  {
        try {
            rs = stmt.executeQuery("SELECT * FROM job WHERE jobname='" + job.getJobname()  + "'");
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            if (rs.next()) {
               job.setJobname(rs.getString("jobname"));
                job.setJob(rs.getString("job"));

//            List list = new ArrayList();
//            list.add(user2);
            } else {
                return null;
            }
        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
        return job;
    }

/*
     *     *
    */
public int manaJobInfoUpdate(Job job2)  {
        int count=0;
        try {
            pstmt = con.prepareStatement("update job set job=? where jobname =?");
//                pstmt.setString(1, user.getNumber());
//                pstmt.setString(2, user.getPwd());
                pstmt.setString(2, job2.getJobname());///////////////
               // pstmt.setString(1, stu.getUsername());/////////////////
                pstmt.setString(1, job2.getJob());
                count = pstmt.executeUpdate();


        } catch (SQLException ex) {
            Logger.getLogger(UserChecker.class.getName()).log(Level.SEVERE, null, ex);
        }
       return count;

       }




     }
